<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件传递</title>
    <script src="./js/vue.js"></script>
    <style>
        /*设置原本的颜色*/
        .divC {
            width: 50px;
            height: 50px;
            border: 1px solid #000000;
            background-color: cornflowerblue;
        }

        /*设置改变后的颜色*/
        .bColor {
            background-color: #cb7a7a;
        }

        /*内部 div*/
        .divC_Div {
            width: 20px;
            height: 20px;
            margin: 15px auto;
            border: 1px solid #000000;
            background-color: #000000;
        }

        .divC_DivColor {
            background-color: red;
        }
    </style>
</head>
<body>
<div id="app">
    <!-- .stop -->
    <div class="divC" :class="{bColor:isShow}" @click="changeColor">
        <div class="divC_Div" :class="{divC_DivColor:isShowSmallColor}" @click.stop="changeSmallColor"></div>
    </div>
    <!-- .prevent -->
    <a href="www.baidu.com" @click.prevent="aClick">点击</a>
    <!-- .self -->
    <div class="divC" :class="{bColor:isShow}" @click.self="changeColor">
        <input type="button" @click="btClick1" value="按钮1">
        <input type="button" @click="btClick2" value="按钮2">
    </div>
    <!-- .once -->
    <div>
        <a href="www.baidu.com" @click.once.prevent="aClick">点击</a>
    </div>
</div>
</body>
</html>
<script>
    new Vue({
        el: '#app',
        data: {
            isShow: false,
            isShowSmallColor: false
        },
        methods: {
            changeColor() {
                this.isShow = !this.isShow
            },
            changeSmallColor() {
                this.isShowSmallColor = !this.isShowSmallColor
            },
            aClick(){
                console.log('点击了')
            },
            btClick1(){
                alert("按钮1点击")
            },
            btClick2(){
                alert("按钮2点击")
            }
        },
        computed: {

        }
    });
</script>

